package com.ty.dictionaries.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.ty.dictionaries.mapper.DictMapper;
import com.ty.utils.pojo.Dict;
import com.ty.utils.pojo.vo.DictVo;
import org.springframework.beans.BeanUtils;

public class DictListener extends AnalysisEventListener<DictVo> {
   /*注入*/
    private DictMapper dictMapper;

    public DictListener (DictMapper dictMapper){
        this.dictMapper=dictMapper;
    }
    //一行一行读取
    @Override
    public void invoke(DictVo dictVo, AnalysisContext analysisContext) {
            //调用数据库添加方法
        Dict dict=new Dict();
        BeanUtils.copyProperties(dictVo,dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
